<template>
  <div class="rank">
    <ranklist-item
      v-for="item in rankList"
      :key="item.id"
      :item="item"
    ></ranklist-item>
  </div>
</template>

<script>
import { getRank, getSheet } from "../api/rank";
import ranklistItem from "@/components/ranklistItem.vue";
export default {
  components: { ranklistItem },
  data() {
    return {
      rankList: [],
    };
  },
  methods: {
    getRankList() {
      getRank().then((res) => {
        // console.log(JSON.parse(JSON.stringify(res)));
        if (res) {
          let arr =[]
          for (let i = 0; i < res.list.length; i++) {
          arr.push(getSheet(res.list[i].id))
          }
          Promise.all(arr).then(val=>{
            // console.log(JSON.parse(JSON.stringify(val)));
            this.rankList=val
          })
        }
      });
    },
  },
  created() {
    this.getRankList();
  },
};
</script>

<style lang="scss" scoped>
.rank {
  padding-top: 80px;
}
</style>
